Repository navigation
Allow users to obtain raw headers. - #198
Merged
Merged
Conversation
We need this for the raw kwarg.
This changes our internal representation of headers to use bytes everywhere, rather than unicode. hyper-h2 actually previously played a bit fast-and-loose with header format internally, meaning that on Python 2 there was quite a bit of implicit encoding/decoding going on when we worked with headers. This should remove that: headers are bytes up until right when we're done with them, at which point they *may* become unicode. Note that becoming unicode is now optional.
Member
Author
Member
|
This looks pretty good to me 👍 |
Member
|
Our netlib.http.Headers class works on bytes as well, so this change is a very welcome addition. 😃 Looks good to me as well! 👍 |
Member
Author
|
Ok, I'm going to land this now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds a new flag that allows users to request 'raw' headers: that is, headers that have not been decoded to unicode and are still in bytes form. This was originally requested by the Twisted developers who use a bytes internal headers representation, though it may well be useful for others.
This change involves quite a substantial internal change: we now have headers move through the body of hyper-h2 in bytes form, and only get encoded at the edge.
This change introduces one unfortunate problem: we need to bump the minimum version of HPACK we can use. I believe this is safe to do in a semver-minor release, as we're only bumping the minor version, so the upgrade should be safe.
The default output for headers remains unicode. That may change in 3.0.0 (per #154), but for now we're leaving it as-is.